<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/18
 * Time: 14:30
 */

namespace app\home\model;

use think\Model;
use traits\model\SoftDelete;

class ProjectBug extends Model
{
    use SoftDelete;
    // 定义时间戳字段名
    protected $createTime = 'ctime';
    protected $updateTime = '';
    protected $deleteTime = 'deleted';
    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    public static $typeCode = [
        0  => '代码错误',
        1  => '测试脚本',
        2  => '安全相关'
    ];

    public static $systemCode = [
        0  => 'windows',
        1  => 'linux',
        2  => 'UNIX'
    ];

    public static $browserCode = [
        0  => '谷歌',
        1  => '火狐',
        2  => 'QQ浏览器',
        3  => '360浏览器',
        4  => 'IE浏览器'
    ];
//0:未确认 1:已确认 2:已解决 3:已关闭 4:激活
    public static $statusCode = [
        0  => '未确认',
        1  => '已确认',
        2  => '已解决',
        3  => '已关闭',
        4  => '激活'
    ];

    public static function getEtimeAttr($time){
        return $time ? date('Y-m-d', $time) : '';
    }

    public static function getTypeAttr($id){
        return \app\home\model\Deploy::where('id',$id)->value('name');
    }

    public static function getCreatorAttr($id){
        return \app\common\model\User::where('id',$id)->value('nick');
    }

    public static function getAssignerAttr($id){
        return \app\common\model\User::where('id',$id)->value('nick');
    }

    public static function getproductIdAttr($id){
        return \app\home\model\Project::where('id',$id)->value('name');
    }

    public static function getStatusAttr($index){
        return self::$statusCode[$index];
    }

    public static function getSystemAttr($id){
        return \app\home\model\Deploy::where('id',$id)->value('name');
    }

    public static function getBrowserAttr($id){
        return \app\home\model\Deploy::where('id',$id)->value('name');
    }

    public static function getBlockIdAttr($id){
        return \app\home\model\Block::where('id',$id)->value('name');
    }

    public function getDeptidAttr($index){
        $dept = ['前端', '后端', '产品经理', '测试', '运维','管理员'];
        return $dept[$index];
    }
}